﻿<%@ WebHandler Language="C#" Class="ProductAddEdit" %>

using System;
using System.Web;
using System.Data;
using System.Data.Common;
using System.Web.SessionState;

public class ProductAddEdit : IHttpHandler, IRequiresSessionState
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";

        /* 管理员信息验证 */
        if (!Admins.IsLogin(true))
            Utils.ShowEnd(context, -2);


        /* 外部数据处理 */

        int Item_Id = Convert.ToInt32(context.Request.Params["Item_Id"].ToString());
        int Orders = Convert.ToInt32(context.Request.Params["Orders"].ToString());
        int Item_Column = Convert.ToInt32(context.Request.Params["Item_Column"].ToString());

        string Item_Name = context.Request.Params["Item_Name"].ToString();
        string Item_Price = context.Request.Params["Item_Price"].ToString();
        string Item_Introduction = context.Request.Params["Item_Introduction"].ToString();
        string Item_Instructions = context.Request.Params["Item_Instructions"].ToString();
        string Property1 = context.Request.Params["Property1"].ToString();
        string Property2 = context.Request.Params["Property2"].ToString();
        string Property3 = context.Request.Params["Property3"].ToString();
        string Property4 = context.Request.Params["Property4"].ToString();
        string Property5 = context.Request.Params["Property5"].ToString();
        int Item_Lang = Convert.ToInt32(context.Request.Params["Lang"].ToString());

        /* 完整性验证 */
        if (Item_Lang < 1 || Item_Lang > 255)
            Utils.ShowEnd(context, -1);
        if (Orders < 1 || Orders > 255)
            Utils.ShowEnd(context, -1);
        if (Item_Column < 1)
            Utils.ShowEnd(context, -1);
        
        if (Item_Name.Length < 2)
            Utils.ShowEnd(context, -1);


        /*执行*/
        Product NewProduct = new Product();
        context.Response.Write(NewProduct.Product_AddEdit(Item_Id, Orders, Item_Column, Item_Name, Item_Price, Item_Introduction, Item_Instructions, Property1, Property2, Property3, Property4, Property5, Item_Lang));


    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}